<template>
  <div class="listBox">
    <div class="listCon" v-for="item in res.list" :key="item.id">
      <div class="info">
        <img :src="`https://ss.lanqb.com/${item.profile.avatar}`" alt="" />
        <p class="nickname">{{ item.profile.nickname }}</p>
      </div>
      <div class="question">
        <div class="q-left">问</div>
        <p class="q-right">{{ item.title }}</p>
      </div>
      <div class="details">
        <div class="d-left">
          <p class="con">{{ item.content }}</p>
        </div>
        <div class="d-right">
          <img :src="`https://ss.lanqb.com/${item.works[0].url}`" alt="" />
        </div>
      </div>
      <div class="teacher-info" v-if="item.adopt_answer">
        <div class="t-info">
          <img src="https://assets-cdn.lanqb.com/makesite.jpg" alt="" />
          <p class="tName">{{ item.adopt_answer.nickname }}</p>
          <p class="t-tag">已采纳</p>
        </div>
        <div class="t-con">
          <p class="t-left">{{ item.adopt_answer.content[0].value }}</p>
          <a href="">APP内查看</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { getCurrentInstance, reactive } from "vue";
const { $axios, $request } =
  getCurrentInstance().appContext.config.globalProperties;

let res = reactive({
  list: [],
});

// https://m.lanqb.com/api/works/qa-list?is_commun_status=0&page=1

$axios(`/lanqb/api/works/qa-list?is_commun_status=0&page=1`).then(
  ({ data }) => {
    res.list = data.works;
    // console.log(res.list);
  }
);
</script>

<style lang="less">
* {
  margin: 0;
  padding: 0;
}
.listBox {
  width: 100vw;
  height: calc(100vh - 40px - 44px - 42px - 50px);
  overflow-y: scroll;
  padding: 0 15px;
  box-sizing: border-box;
  &::-webkit-scrollbar {
    display: none;
  }
  .listCon {
    border-bottom: 2px solid #f7f7f7;
    padding: 20px 0;
    .info {
      display: flex;
      align-items: center;
      img {
        width: 32px;
        height: 32px;
        border-radius: 50%;
      }
      .nickname {
        margin-left: 5px;
        color: #000000;
        font-size: 15px;
      }
    }
    .question {
      display: flex;
      align-items: center;
      margin-top: 15px;
      .q-left {
        width: 20px;
        height: 20px;
        background: linear-gradient(324deg, #008bff, #006bfe);
        line-height: 20px;
        text-align: center;
        color: #ffffff;
        border-radius: 5px;
        font-size: 12px;
      }
      .q-right {
        margin-left: 5px;
        color: #1a1b1e;
        font-size: 18px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
      }
    }
    .details {
      display: flex;
      justify-content: space-between;
      margin-top: 15px;
      .d-left {
        width: 266px;
        .con {
          font-size: 15px;
          color: #5b6164;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
        }
      }
      .d-right {
        img {
          width: 65px;
          height: 65px;
          border-radius: 5px;
        }
      }
    }
    .teacher-info {
      padding: 10px;
      background-color: #f7f7f7;
      .t-info {
        display: flex;
        align-items: center;
        img {
          width: 20px;
          height: 20px;
          border-radius: 50%;
        }
        .tName {
          font-size: 14px;
          color: #3f4345;
          margin-left: 5px;
        }
        .t-tag {
          width: 53px;
          height: 20px;
          background: linear-gradient(90deg, #ffed70, #ffd865);
          font-size: 12px;
          color: #4c2915;
          line-height: 20px;
          text-align: center;
          border-radius: 15px;
          margin-left: 5px;
        }
      }
      .t-con {
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        .t-left {
          width: 255px;
          font-size: 14px;
          color: #5b6164;
        }
        a {
          font-size: 14px;
          color: #457eec;
        }
      }
    }
  }
}
</style>
